#include <fmt/core.h>
#include "utils/myzip.hpp"
#include <string>
#include "utils/my7zip.hpp"
#include "utils/string_helper.h"

namespace superunzip
{
    bool unzip_file(const char *arg1, const char *arg2)
    {
        auto zip_path = superunzip::utils::gbk_to_utf8(arg1);
        auto out_dir = superunzip::utils::gbk_to_utf8(arg2);

        fmt::println("开始解压: {}", zip_path.c_str());
        fmt::println("解压目录：{}", out_dir.c_str());

        if (superunzip::utils::endsWith(zip_path, ".zip"))
        {
            superunzip::utils::extractZip(zip_path, out_dir);
        }
        else if (superunzip::utils::endsWith(zip_path, ".7z"))
        {
            superunzip::utils::extract7Zip(zip_path, out_dir);
        }
        else
        {
            fmt::println("不支持解压该类型的文件！");
            return false;
        }

        fmt::println("解压完成：{}", out_dir.c_str());
        return true;
    }
}